﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Data.Common;
using System.Text;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        /*
                String conn_str = System.Configuration.ConfigurationManager.ConnectionStrings["conn_string"].ConnectionString;
                SqlConnection conn=new SqlConnection(conn_str);
                try{
                    conn.Open();
                    SqlCommand sqlcmd = conn.CreateCommand();
                    sqlcmd.CommandText = "select * from [table]";
                    SqlDataReader sqlreader = sqlcmd.ExecuteReader();  
                    if (sqlreader.Read())error_mes.Text = sqlreader["name"].ToString();
                    sqlreader.Close();
                }
                catch (Exception ex)
                {
                    error_mes.Text = ex.Message.ToString();
                }
        */
        
        ////测试代码，成功读取数据库
        //DbConnection conn = (new DBConnector()).GetConnection();
        //DbCommand command = conn.CreateCommand();
        //command.CommandText = "select * from test";
        //DbDataReader reader = command.ExecuteReader();

        //StringBuilder sb = new StringBuilder();
        //while (reader.Read())
        //{
        //    sb.Append("username:").Append(reader.GetString(0)).Append("\n")
        //    .Append("password:").Append(reader.GetString(1)).Append("\n");
        //}
        //reader.Close();
        //conn.Close();
        
        string strHeader = "名师札记";
        //strHeader = sb.ToString();
        string strContent = "一般而言，语文是语言文字的简约式统称。语文是听、说、读、写、译、编等语言文字的能力和语言知识及文化知识的统称。语文能力是学习其他学科和科学的基础，语文知识几乎包罗万象。语文也是一门重要的人文社会科学（学科），是人们相互交流思想等的工具。哲学认为语文是进行表述、记录、传递口头或书面信息的文字言词的物质存在形式；语文是描述事实、引证思维、陈述思想、表达意志、抒发情怀以及改造事物和思想的信息定位的一种意识存在内容。";
        strContent = ((new Article()).GetLatestArticle("翰墨篇籍").ToString());
        slider_add(strHeader, strContent, "#");
        slider_add("Header2", "Content2", "#");



    }

    private void debug(string msg)
    {
        StreamWriter sw = new StreamWriter(this.Server.MapPath("debug.log"));
        sw.Write(msg);
        sw.Close();
    }

    private void slider_add(String _head, String _content, string _href)
    {
        slider_content.InnerHtml += "<li><div class=\"inner\"><h2><a href=\"" + _href + "\">" +
                  _head+"</a></h2>"+_content
                   + "</div></li>";
    }
}